package chapter13.section6;
//程序13-5 存储过程调用

import java.sql.*;

public class CallableStatementDemo {
    public static void main(String[] args) {
        String url = "jdbc:mysql://localhost:3306/bank?user=root&password=123456";
        Connection con = null;
        try {
            con = DriverManager.getConnection(url);
            // String  procName="{?=call sumBalance(?,?)}";
            String procName = "{call sumBalance(?,?,?)}";
            CallableStatement cstmt = con.prepareCall(procName);
            cstmt.setInt(1, 0);
            cstmt.setInt(2, 60000);
            cstmt.registerOutParameter(3, Types.INTEGER);
            cstmt.execute();
            System.out.println(cstmt.getInt(3));
            cstmt.close();
            con.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
